package com.starlink.controller.admin;

import com.starlink.common.WebResponse;
import com.starlink.common.annotation.WebAccess;
import com.github.pagehelper.PageInfo;
import com.starlink.model.request.DepositPriceSetRequest;
import com.starlink.service.DepositPriceSetService;
import com.starlink.model.vo.DepositPriceSetVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @author zhanghong
 */
@RestController
@RequestMapping("/admin/set")
@Api(value = "【管理端】押金金额设置模块", tags = {"【管理端】押金金额设置模块"})
public class AdminDepositPriceSetController {

    @Autowired
    private DepositPriceSetService depositPriceSetService;

//    @WebAccess(login = true)
//    @ApiOperation(value = "根据主键查询", httpMethod = "POST")
//    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
//    @PostMapping("/get/{id}")
//    public WebResponse<DepositPriceSetVO> getByKey(HttpServletRequest request, @PathVariable("id") long id) {
//        return WebResponse.build(depositPriceSetService.getByKey(id));
//    }
//
//    @WebAccess(login = true)
//    @ApiOperation("分页查询")
//    @PostMapping("/pageQuery")
//    public WebResponse<PageInfo<DepositPriceSetVO>> pageQuery(@SortDefault(sort = {"create_time"}, direction = Sort.Direction.DESC) Pageable pageable,
//                                                           @RequestBody DepositPriceSetRequest request) {
//        return WebResponse.build(depositPriceSetService.pageQuery(pageable,request));
//    }

    @WebAccess(login = true)
    @ApiOperation("查询")
    @PostMapping("/selectOne")
    public WebResponse<DepositPriceSetVO> selectOne() {
        return WebResponse.build(depositPriceSetService.selectOne());
    }

    @WebAccess(login = true)
    @ApiOperation("新增")
    @PostMapping("/add")
    public WebResponse<Boolean> add(@Valid @RequestBody DepositPriceSetRequest request) {
        return WebResponse.build(depositPriceSetService.add(request));
    }

    @WebAccess(login = true)
    @ApiOperation("修改")
    @PostMapping("/update")
    public WebResponse<Boolean> updateByKey(@Valid @RequestBody DepositPriceSetRequest request) {
        return WebResponse.build(depositPriceSetService.updateByKey(request));
    }

//    @WebAccess(login = true)
//    @ApiOperation("删除")
//    @PostMapping("/delete")
//    public WebResponse<Boolean> deleteByKey(@RequestParam("ids") String ids) {
//        return WebResponse.build(depositPriceSetService.deleteDOByIds(ids));
//    }
}
